package avicit.bdp.dms.dss.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.bdp.core.constant.Constants;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import avicit.platform6.core.properties.PlatformConstant;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * 数据资源用户表实体
 */
@ApiModel(value = "DssUserDTO", description = "数据资源用户表")
@Table(name = "bdp_dss_user")
public class DssUserDTO extends BaseDTO {

    /**
     * 主键
     */
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "主键")
    @Column(name = "id")
    @Id
    @javax.persistence.Id
    private String id;

    /**
     * 用户ID
     */
    @LogField
    @ApiModelProperty(value = "用户ID")
    @FieldRemark(column = "userId", field = "userId", name = "用户ID")
    @Column(name = "user_id")
    private String userId;

    /**
     * 用户ID
     */
    @LogField
    @ApiModelProperty(value = "用户名")
    @FieldRemark(column = "userName", field = "userName", name = "用户名称")
    @Column(name = "user_name")
    private String userName;
    /**
     * token表示
     */
    @LogField
    @ApiModelProperty(value = "token表示")
    @FieldRemark(column = "token", field = "token", name = "token表示")
    @Column(name = "token")
    private String token;
    /**
     * 日调用次数
     */
    @LogField
    @ApiModelProperty(value = "日调用次数")
    @FieldRemark(column = "dayCount", field = "dayCount", name = "日调用次数")
    @Column(name = "day_count")
    private Integer dayCount;
    /**
     * 有效日期,null表示永久
     */
    @LogField
    @ApiModelProperty(value = "有效日期,null表示永久")
    @FieldRemark(column = "validDate", field = "validDate", name = "有效日期,null表示永久")
    @JsonFormat(timezone = "GMT+8", pattern = Constants.YYYY_MM_DD)
    @Column(name = "valid_date")
    private Date validDate;

    @Transient
    private String validDateStr;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Integer getDayCount() {
        return dayCount;
    }

    public void setDayCount(Integer dayCount) {
        this.dayCount = dayCount;
    }

    public Date getValidDate() {
        return validDate;
    }

    public void setValidDate(Date validDate) {
        this.validDate = validDate;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getValidDateStr() {
        return validDateStr;
    }

    public void setValidDateStr(String validDateStr) {
        this.validDateStr = validDateStr;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "服务用户模块";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "服务用户";
        } else {
            return super.logTitle;
        }
    }

    @Override
    public PlatformConstant.LogType getLogType() {
        if (super.logType == null) {
            return PlatformConstant.LogType.module_operate;
        } else {
            return super.logType;
        }
    }
}

